﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" />
    <link href="../Frozenui1.3/css/frozen.css" rel="stylesheet" />
    <script src="../JS/layer/layer.m.js"></script>
    <script src="../JS/zepto.min.js"></script>
    <script src="../Frozenui1.3/js/frozen.js"></script>
    <script src="../JS/avalon.mobile.min.js"></script>
    <script src="../JS/MobileCom.js?v=1.2"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script>
        document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
            //隐藏右上角按钮
            WeixinJSBridge.call('hideOptionMenu');
        });

        var height = 0;
        var width = 0;
        var strId = "";
        var strType = MobileCom.getQueryString("Type");

        var model = avalon.define({
            $id: "lcmodel",
            code: "LCSP",
            lg: "",
            sh: "",
            pdid: strType,
            ptype:"",
            rdm: Math.random(),
            ctData: { "LeiBie": "", "Content": "", "ShenQingRen": "", "intProcessStanceid": "", "Files": "" },
            TempData:[],
            content: "",
            wximg:"",
            savedata: function () {
                model.lg = $.loading({
                    content: '保存中...',
                })

                psmodel.savedata();

            },
            bjk: function () {

                var tc = layer.open({
                    type: 1,
                    //content:$("#bmxx").html(),
                    //title: "活动简介",
                    content: '<div class="ui-form-item ui-form-item-textarea ui-border-b" style="width:' + (width - 76) + 'px;height:200px"><textarea id="hdjjbjk" style="padding-left: 0;height:170px;border: 1px solid #e0e0e0;" placeholder="请输入申请内容">' + model.ctData.Content + '</textarea></div>',
                    btn: ['确认', '取消'],
                    shadeClose: false,
                    yes: function () {
                        model.ctData.Content = $("#hdjjbjk").val();
                        if ($("#hdjjbjk").val() != "") {
                            $("#hdjj").removeClass("ui-txt-muted");
                            $("#hdjj").html($("#hdjjbjk").val());
                        }
                        else {
                            $("#hdjj").addClass("ui-txt-muted");
                            $("#hdjj").html("请输入申请内容");
                        }

                        layer.close(tc);

                    }, no: function () {
                    }
                })
                $("#hdjjbjk").focus();
            }

        });

        function Sava() {
            if (!model.ctData.intProcessStanceid) {
                model.lg.hide();
                $.tips({
                    content: "保存失败",
                    stayTime: 2000,
                    type: "warn"
                })
            }
            else {
                model.ctData.Files = "";
                $("#imglist .tpli").each(function () {
                    if ($(this).hasClass("wximg")) { //微信上传未处理的图片
                        if (model.wximg) {
                            model.wximg += ",";
                        }
                        model.wximg += $(this).attr("itemid");

                    } else {
                        if (model.ctData.Files) {
                            model.ctData.Files = model.ctData.Files + ',' + $(this).attr("itemid");
                        }
                        else {
                            model.ctData.Files = $(this).attr("itemid");
                        }
                    }

                })

                $("#tempcontent").children().each(function () {
                    var tempValue = "";
                    if ($(this).attr("datatype") != "check") {
                        tempValue = $(this).find("input,select,textarea").val();
                    } else if ($(this).attr("datatype") == "check") {
                        tempValue = $(this).find("input[type=checkbox]:checked").val();
                    }
                    model.TempData.push({ dataname: $(this).attr("dataname"), datatype: $(this).attr("datatype"), value: tempValue })
                })
                var content = JSON.stringify(model.TempData.$model);
                var srdata = model.ctData.$model;
                srdata.Content = content;//保存模版对应的数据

                $.post("/API/WXAPI.ashx?Action=ADDLCSP&r=" + Math.random(), { "P1": JSON.stringify(srdata) ,P2:model.wximg}, function (data) {
                    model.lg.hide();
                    var data = $.parseJSON(data);
                    if (data.ErrorMsg == "") {
                        $("button").hide();
                        var el = $.tips({
                            content: "保存成功！",
                            stayTime: 2000,
                            type: "success"
                        })
                        el.on("tips:hide", function () {
                            //window.location.reload();
                            window.location.replace(location.href);
                        })
                    }
                    else {
                        $.tips({
                            content: "保存失败，原因：" + data.ErrorMsg,
                            stayTime: 2000,
                            type: "warn"
                        })
                    }
                })
            }
        }

        avalon.ready(function () {
            width = document.documentElement.clientWidth;
            height = document.documentElement.clientHeight;
            model.lg = $.loading({
                content: '加载中...',
            })
            $.getJSON('/API/FTAPI.ashx?Action=GETLCSPMODEL', { P1: strId, P2: strType }, function (resultData) {
                if (resultData.ErrorMsg == "") {
                    if (!strId) {
                        model.content = resultData.Result1.Tempcontent;
                        model.ctData.LeiBie = resultData.Result1.ProcessName;//流程名称
                        model.ptype = resultData.Result1.ProcessType;
                        setTimeout("load()", 500);
                        //$("select .form-control").parent().addClass("ui-select");
                        $("select").each(function () {
                            if ($(this).hasClass("form-control"))
                            {
                                $(this).parent().addClass("ui-select");
                            }
                        })
                    }
                }
            })
            $.post("/API/SZHLAPI.ashx?Action=GetUserInfo&r=" + Math.random(), {}, function (data) {

                var data = $.parseJSON(data);
                if (data.ErrorMsg == "") {
                    model.ctData.ShenQingRen = data.Result.User.UserRealName;
                }
            })

            MobileCom.uploadimg();

        })
        function back() {
            window.location.replace("UI_LCSP_LCLIST.html?r=" + Math.random());
        }
    </script>
    <style type="text/css">
        .ui-select {
            border: none;
            border: 0;
            background-color: #fff;
            appearance: none;
            -moz-appearance: none; /* Firefox */
            -webkit-appearance: none; /* Safari 和 Chrome */
        }

        .ms-controller, [ms-controller] {
            display: none;
        }

        .col-sm-9 {
            min-height: 44px;
            margin-left:95px;
        }
        .checkbox-inline input {
            width: auto;
        }
        .data-control {
            border-bottom: 1px solid #e0e0e0;
            position: relative;
            font-size: 16px;
            min-height: 44px;
            line-height: 44px;
            padding-right: 15px;
            padding-left: 15px;
        }
        .ui-form-item .checkbox-inline {
            position:relative !important;
            margin-right:10px;
        }
        .form-control {
            padding-left: 0 !important;
        }

        input[type=checkbox] {
            box-sizing: content-box;
            -webkit-appearance:checkbox;
        }

        select {
            -webkit-appearance: none;
            border: 0;
            background: 0 0;
            width: 100%;
            padding-right: 14px;
        }


        .szhl_UEEDIT {
            margin-top: 13px;
            min-height: 88px;
            max-height: 220px;
        }
        .ui-form-item .wspan {
            width: 100%;
            display: -webkit-box;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
            -webkit-appearance: none;
            border: 0;
            background: 0 0;
            padding-left: 95px;
        }
        .ui-form-item .wspan img {
            width: 50px;
            height: 50px;
            padding-right: 3px;
        }

        .sctp {
            color: #18b4ed;
            right: 4px;
            top: -5px;
            z-index: 9;
            width: 20px;
            height: 20px;
            background: #fff;
            border-radius: 13px;
            line-height: 20px;
            text-indent: -3px;
            position: absolute;
            font-size: 25px;
        }

        .imgxl {
            position: relative;
            float: left;
            padding-top: 0;
            height: 50px;
            width: 50px;
            padding-right: 10px;
            margin-left: 0px;
            margin-bottom: 5px;
        }

        .tpxs {
            height: 50px;
            width: 50px;
            position: absolute;
            top: 0;
            left: 0;
            z-index: 1;
            background-repeat: no-repeat;
            -webkit-background-size: cover;
        }
    </style>
    <title>流程审批</title>
</head>
<body ms-controller="lcmodel">
    <div id="content">
        <header class="ui-header ui-header-stable ui-border-b">
            <i class="ui-icon-return" onclick="back()"></i>
            <h1>{{ctData.LeiBie}}</h1>
        </header>
        <div class="ui-footer ui-footer-stable ui-btn-group ui-border-t">
            <button class="ui-btn-lg ui-btn-primary" ms-click="savedata()">
                新增流程审批
            </button>
        </div>
        <section class="ui-container">
            <div class="ui-form ui-border-t">
                <div class="ui-form-item ui-border-b">
                    <label>
                        流程类别
                    </label>
                    <span style="padding-left:95px">{{ctData.LeiBie}}</span>
                </div>
                <div class="ui-form-item ui-border-b">
                    <label>
                        申请人
                    </label>
                    <span style="padding-left:95px">{{ctData.ShenQingRen}}</span>
                </div>

                <div id="tempcontent" class="ui-form-item ui-border-b" style="height:auto;padding-left:0;padding-right:0;">
                    {{content|html}}
                </div>

                <div ms-include-src="UI_PROCESS.html?r={{rdm}}">

                </div>

                <div class="ui-form-item ui-border-b" style="height:auto;min-height:44px">
                    <label>
                        上传图片
                    </label>

                    <div class="wspan" style="padding-top: 5px; height: auto;display:block">
                        <ul id="imglist">
                            <li class="imgxl scli"><img id="add_pit" src="../Images/icon-add.png" /></li>
                        </ul>
                        <div style="clear:both"></div>
                    </div>
                </div>
            </div>
        </section>
    </div>

</body>
</html>
